const {
  DataTypes
} = require('sequelize');
module.exports = sequelize => {
  const attributes = {
    itemId: {
      type: DataTypes.INTEGER(11),
      allowNull: false,
      defaultValue: null,
      primaryKey: true,
      autoIncrement: true,
      comment: "商品编号",
      field: "item_id"
    },
    itemName: {
      type: DataTypes.STRING(255),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "商品名称",
      field: "item_name"
    },
    skuId: {
      type: DataTypes.STRING(100),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "SKU编码",
      field: "sku_id"
    },
    spuId: {
      type: DataTypes.STRING(100),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "SPU编码;对应聚水潭中的款式编码i_id",
      field: "spu_id"
    },
    brand: {
      type: DataTypes.STRING(100),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "品牌;对应聚水潭中的商品编码",
      field: "brand"
    },
    unit: {
      type: DataTypes.STRING(20),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "单位",
      field: "unit"
    },
    category: {
      type: DataTypes.STRING(100),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "分类",
      field: "category"
    },
    basePrice: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "成本价;核算利润用，仅做参考",
      field: "base_price"
    },
    price: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "基本售价",
      field: "price"
    },
    pic: {
      type: DataTypes.STRING(255),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "图片地址",
      field: "pic"
    },
    remark: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "备注",
      field: "remark"
    },
    supplierName: {
      type: DataTypes.STRING(100),
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "供应商名称",
      field: "supplier_name"
    },
    properties: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "颜色及规格;蓝色;XXL",
      field: "properties"
    }
  };
  const options = {
    tableName: "item",
    comment: "",
    indexes: [{
      name: "unique_sku_id",
      unique: false,
      type: "BTREE",
      fields: ["sku_id"]
    }]
  };
  const ItemModel = sequelize.define("itemModel", attributes, options);
  return ItemModel;
};